<?php

namespace App\Http\Controllers\Admin;

use App\Admin\Form;
use App\Admin\Grid;
use App\Admin\Grid\Displayers\Actions;
use App\Admin\Layout\Content;
use App\Admin\Traits\ModelForm;
use App\Models\LottoPlayer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class LottoPlayerController extends Controller
{
    public function index()
    {
        return \Admin::content(function (Content $content) {
            $content->header('参与人员');
            $content->description('所有参与人员');
            $content->body($this->grid()->render());
        });
    }

    protected function grid()
    {
        return LottoPlayer::grid(function (Grid $grid) {
            $grid->id('编号')->sortable();

            $grid->column('lotto.title', '抽奖');

            $grid->column('user.nickname', '参与人');

            $grid->award('中奖');

            $grid->created_at('参与时间');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->like('user.nickname', '参与人');
                $filter->like('lotto.title', '抽奖');
                $filter->like('award', '中奖');
            });

            $grid->actions(function (Actions $actions) {
                $actions->disableEdit();
            });

            $grid->disableExport();
        });
    }

    public function destroy($id)
    {
        return $this->form()->destroy($id);
    }

    protected function form()
    {
        return LottoPlayer::form(function (Form $form) {
        });
    }
}
